# from pyecharts.charts import Bar
# from pyecharts.options import LabelOpts
# bar=Bar()
# bar.add_xaxis(["中国","美国","英国"])
# bar.add_yaxis("GDP",[30,20,10],label_opts=LabelOpts(position="right"))
# bar.reversal_axis()
# bar.render("GDP柱状图.html")
#=======================================================
# # 基础柱状图
# from pyecharts.charts import Bar,Timeline
# from pyecharts.options import *
# from pyecharts.globals import ThemeType
# bar1=Bar()
# bar2=Bar()
# bar3=Bar()
#
# bar1.add_xaxis(["中国","美国","英国"])
# bar1.add_yaxis("GDP",[30,20,10],label_opts=LabelOpts(position="right"))
# bar1.reversal_axis()
#
# bar2.add_xaxis(["中国","美国","英国"])
# bar2.add_yaxis("GDP",[40,30,20],label_opts=LabelOpts(position="right"))
# bar2.reversal_axis()
#
# bar3.add_xaxis(["中国","美国","英国"])
# bar3.add_yaxis("GDP",[50,40,30],label_opts=LabelOpts(position="right"))
# bar3.reversal_axis()
#
# timeline=Timeline({"theme":ThemeType.LIGHT})
# timeline.add(bar1,"点1")
# timeline.add(bar2,"点2")
# timeline.add(bar3,"点3")
#
# timeline.add_schema(
#     play_interval=1000,
#     is_timeline_show=True,
#     is_auto_play=True,
#     is_loop_play=True
# )
#
# timeline.render("基础时间线柱状图.html")
# ============================================
# # 柱状图案例
# from pyecharts.charts import Bar,Timeline
# from pyecharts.options import *
# from pyecharts.globals import ThemeType
#
# f=open("C:\\python的学习\\python_learning_-hm\可视化案例数据\动态柱状图数据\\1960-2019全球GDP数据.csv","r",encoding="GB2312")
# data_lines=f.readlines()
# f.close()
# data_lines.pop(0)
#
# data_dict={}
# for line in data_lines:
#     year=int(line.split(",")[0])
#     country=line.split(",")[1]
#     gdp=float(line.split(",")[2])
#     try:
#         data_dict[year].append([country,gdp])
#     except KeyError:
#         data_dict[year]=[]
#         data_dict[year].append([country,gdp])
#
# time_line=Timeline({"theme":ThemeType.LIGHT})
# sorted_year_list=sorted(data_dict.keys())
# for year in sorted_year_list:
#     data_dict[year].sort(key=lambda element:element[1],reverse=True)
#     year_data=data_dict[year][0:8]
#     x_data=[]
#     y_data=[]
#     for country_gdp in year_data:
#         x_data.append(country_gdp[0])
#         y_data.append(country_gdp[1]/100000000)
#
#     bar=Bar()
#     x_data.reverse()
#     y_data.reverse()
#     bar.add_xaxis(x_data)
#     bar.add_yaxis("GDP(亿)",y_data,label_opts=LabelOpts(position="right"))
#
#     bar.reversal_axis()
#     bar.set_global_opts(
#         title_opts=TitleOpts(title=f"{year}年全球GDP前八")
#     )
#     time_line.add(bar,str(year))
#
#
# time_line.add_schema(
#     play_interval=1000,
#     is_timeline_show=True,
#     is_auto_play=True,
#     is_loop_play=True
# )
# time_line.render("1960—2019全球GDP前八.html")
# # 常见的魔术方法
# class Student:
#     def __init__(self,name,age):
#         self.name=name
#         self.age=age
#     def __lt__(self, other):
#         return self.age< other.age
#     def __le__(self, other):
#         return self.age<=other.age
#     def __eq__(self, other):
#         return self.age==other.age
#     def __str__(self):
#         return f"Student类对象的年龄：{self.age},姓名：{self.name}"
#
# stu1=Student("周杰伦",99)
# stu2=Student("林俊杰",99)
# print(stu1)
# print(stu2)
# print(stu1>stu2)
# print(stu1>=stu2)
# print(stu1==stu2)
# ========================================================================
# # 继承
# class Phone:
#     IMEI=None
#     producer="XXL"
#     def call_by_4g(self):
#         print("4g通话")
#
# class NFCReader:
#     nfc_type="第五代"
#     producer="HM"
#     def read_card(self):
#         print("NFC读卡")
#     def write_card(self):
#         print("NFC写卡")
#
# class RemoteControl:
#     rc_type="红外遥控"
#     def control(self):
#         print("红外遥控开启")
#
# class Myphone(Phone,NFCReader,RemoteControl):
#     pass   #代表空 不是实现任何东西
#
# phone=Myphone()
# phone.write_card()
# print(phone.producer) #多继承 先继承的优先级高
# ===============================================
# # 复写父类成员
# class Phone:
#     IMEI=None
#     producer="ITCAST"
#     def call_BY_5G(self):
#         print("使用5g通话")
#
# class Myphone(Phone):
#     producer = "ITHEIMA"
#     def call_BY_5G(self):
#         print("省电模式")
#         print(f"父类的厂商{Phone.producer}")
#         Phone.call_BY_5G(self)
#         print("----------------------------")
#         print(f"父类的厂商{super().producer}")
#         super().call_BY_5G()
#         print("关闭省电模式")
#
# phone=Myphone()
# print(phone.producer)
# phone.call_BY_5G()
#==============================================================
# # 类型注解
# import json
#
# var_1:int=10
# var_2:str="itheima"
# var_3=True          #type: bool
# class Student:
#     pass
# var_4:Student=Student()
# my_list:list=[1,2,3]
# my_tuple:tuple[str,int]=("xxl",13)
# my_dict:dict[str,str]={"XXL":"OK"}
# var_5=json.loads('{"name":"XXL"}')   #type:dict[str,str]
# def func():
#     return 10
# var_6=func() #type:int
# var_7:int="XXL"
#====================================================
# # 类型注解2
# #      变量：加=         函数,方法中形参：加冒号
# v : list=[2]
# v.append(5)
# print(v)
# class Phone:
#     def add(self,x:int,y:int):
#         return x+y
# p=Phone()
# print(p.add(1,2))
#
# def func(data:list)->list:
#     return data
#
# func(2)
# print(func(4))
# # 描述混合类型：Union
# from typing import Union
# my_list:list[Union[str,int]]=[12,"XXL"]
# def func(data:Union[list,int])->Union[list,int]:
#     return data
# data1=["xxl",12,"XXL"]
# data=func(data1)
# print(data)
#
# def funcc(data2:list[Union[str,int]])->list[Union[str,int]]:
#     return data2
# data3=["xxl",12]
# print(funcc(data3))
# =========================================================
# 多态 抽象类
class AC:
    def make_cool(self):
        pass
    def make_hot(self):
        pass
    def swing_lr(self):
        pass

class Meide(AC):
    def make_cool(self):
        print("Meide制冷")
    def make_hot(self):
        print("Meide制热")
    def swing_lr(self):
        print("Meide左右摆风")


class Gree(AC):
    def make_cool(self):
        print("Gree制冷")

    def make_hot(self):
        print("Gree制热")

    def swing_lr(self):
        print("Gree左右摆风")

def make__cool(ac:AC):
    ac.make_cool()

meide=Meide()
gree=Gree()

make__cool(meide)
make__cool(gree)
